#pragma once
#include "vertex_buffer.h"
#include "index_buffer.h"
#include "shader_catalog.h"
#include "texture_catalog.h"
#include "vector3.h"
#include "matrix_stack.h"
#include "render_target.h"
#include "refc_ptr.h"

namespace krryn{
namespace view{
	enum draw_mode{
		mode_point_list,
		mode_line_list,
		mode_line_strip,
		mode_triangle_list,
		mode_triangle_strip,
		mode_triangle_fan,
	};

	class render_operation{
	public:
		krryn::core::refc_ptr<vertex_buffer> m_VertexBuffer;
		krryn::core::refc_ptr<index_buffer> m_IndexBuffer;
		vertex_format m_Format;
		draw_mode m_DrawMode;
	};

	enum render_buffers{
		color_buffer = 1,
		depth_buffer = 2,
		stencil_buffer = 4
	};

	enum matrix_type{
		matrix_projection,
		matrix_modelview,
		matrix_type_count
	};

	class renderer{
	public:
		renderer();

		virtual void clear_buffers(int a_Buffers, math::color3 a_Color = math::color3(0, 0, 0), float a_Depth = 1, unsigned short a_Stencil = 0) = 0;
		virtual void render(render_operation &operation) = 0;

		virtual krryn::core::refc_ptr<shader_catalog> get_shader_catalog() = 0;
		virtual krryn::core::refc_ptr<texture_catalog> get_texture_catalog() = 0;

		virtual krryn::math::matrix_stack &get_matrix_stack(matrix_type a_Type) = 0;
		virtual void set_texture(unsigned int a_Unit, bool a_Enabled, krryn::core::refc_ptr<texture> a_Texture) = 0;
		virtual krryn::core::refc_ptr<index_buffer> create_index_buffer(size_t a_NumberOfIndices, index_buffer_format a_Format) = 0;
		virtual krryn::core::refc_ptr<vertex_buffer> create_vertex_buffer(size_t a_VertexSizeInBytes, size_t a_NumberOfVertices) = 0;
		virtual krryn::core::refc_ptr<render_target> create_render_target(int a_Width, int a_Height) = 0;

		render_operation get_dummy_quad();
	private:
		render_operation *m_Quad;
	};
}
}